<template>
  <a-drawer
    :maskClosable="false"
    :destroyOnClose="true"
    :title="title"
    :width="width"
    :keyboard="false"
    placement="right"
    :closable="false"
    @close="close"
    :visible="visible">
    <!-- 展示内容的区域 -->
     <!-- 因为slot里面的内容通过对status的watch来进行控制，为了避免同一个status不刷新的问题，得清除掉这个slot
      所以用destroyOnclose -->
     <!-- 并不做任何关联操作，插槽内的内容的操作都通过父组件来控制 -->
    <slot></slot>
    <div class="drawer-footer">
      <a-popconfirm title="确定关闭弹窗吗?" @confirm="handleCancel" :getPopupContainer="(node) =>  node.parentNode" v-if="isShowCloseBtn">
        <a-button style="margin-bottom: 0;">关闭</a-button>
      </a-popconfirm>
      <a-button v-if="showSaveBtn" @click="handleOk"  :disabled="buttonDisable" type="primary" style="margin-bottom: 0;">提交</a-button>
    </div>
  </a-drawer>
</template>

<script>
  export default {
    name: 'simpleDrawer',
    components: {
    },
    props: {
      title: {
        type: String,
        default: '新增'
      },
      width:{
        type: Number,
        default: 1000
      },
      showSaveBtn:{
        type: Boolean,
        default: true
      },
      buttonDisable:{
        type: Boolean,
        default: false
      },
      isShowCloseBtn:{
        type: Boolean,
        default: true
      }
    },
    data () {
      return {
        visible:false,
      }
    },
    methods: {
      close () {
        this.visible = false;
      },
      submitCallback(type, record) {
      },
      handleOk(){
        this.$emit("clickSubmit")
        // 关闭弹窗由父组件调用，父组件接口调用成功后关闭弹窗
      },
      handleCancel(){
        this.close()
      }
    }
  }
</script>

<style lang="less" scoped>
/** Button按钮间距 */
  .ant-btn {
    margin-left: 30px;
    margin-bottom: 30px;
    float: right;
  }
  .drawer-footer{
    position: absolute;
    bottom: -8px;
    width: 100%;
    border-top: 1px solid #e8e8e8;
    padding: 10px 16px;
    text-align: right;
    left: 0;
    background: #fff;
    border-radius: 0 0 2px 2px;
    z-index:9999999
  }
</style>
